package cn.hxzy.mapper;

import cn.hxzy.domain.Video;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author niuyi
 * @since 2024-06-22
 */
public interface VideoMapper extends BaseMapper<Video> {

    //查此课程所有视频
    @Select("SELECT COUNT(0) FROM sys_video WHERE section_id IN(\n" +
            "SELECT section_id FROM sys_section WHERE chapter_id IN(\n" +
            "SELECT chapter_id FROM sys_chapter WHERE course_id=#{courseId}))")
    double selectCount(Long courseId);

    //查此课程学习完的视频个数
    @Select("SELECT COUNT(0) FROM sys_video WHERE section_id IN(\n" +
            "SELECT section_id FROM sys_section WHERE chapter_id IN(\n" +
            "SELECT chapter_id FROM sys_chapter WHERE course_id=#{courseId})) AND video_bfb=100")
    double selectNum(Long courseId);

    @Select("SELECT video_jd_bfb FROM sys_video_jd WHERE user_id=#{userId} AND video_id = #{videoId}")
    String selectVideoJd(Integer userId,Integer videoId);
}
